﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business;
using Application;

namespace PictureControls
{
    public partial class UpdateImageDetails : System.Web.UI.UserControl
    {
        public string PictureId;
        
        public string ImgTitle
        {
            set { lblTitle.Text = value; txtTitleModify.Text = value; }
        }

        public string ImgDesc
        {
            set { pDesc.InnerText = value; txtDescModify.Text = value; }
        }

        public string ImgUrl
        {
            set { imgItself.ImageUrl = value; }
        }

        /*public string myAjaxBehaviourId
        {
           // set { myAjaxPanel.BehaviorID = value; }
        }*/

        protected void Page_Load(object sender, EventArgs e)
        {

        }
        private void setNewValues()
        {
            VOImage img = BusinessImage.GetImageById(PictureId);
            lblTitle.Text = img.Title;
            pDesc.InnerText = img.Description;
            txtTitleModify.Text = img.Title;
            txtDescModify.Text = img.Description;
        }

        protected void save_Click(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(3000);
            VOImage imgToUpdate = new VOImage();
            imgToUpdate.Id = PictureId;
            imgToUpdate.Title = txtTitleModify.Text;
            imgToUpdate.Description = txtDescModify.Text;
            BusinessImage.UpdateImage(imgToUpdate);
            setNewValues();
            updatePanelImgDesc.Update();
        }

    }
}